const { build, buildSync, serve } = require("esbuild");
async function runBuild() {
  const result = await build({
    absWorkingDir: process.cwd(),
    entryPoints: ["src/index.jsx"],
    outdir: "dist",
    bundle: true,
    format: "esm",
    external: [],
    splitting: true,
    sourcemap: true,
    metafile: true,
    minify: false,
    watch: false,
    write: true,
    loader: {
      ".png": "base64",
    },
  });
  console.log(result);
}

// function runBuild() {
//   serve(
//     {
//       port: 8000,
//       // 静态资源目录
//       servedir: "./dist",
//     },
//     {
//       absWorkingDir: process.cwd(),
//       entryPoints: ["./src/test.jsx"],
//       bundle: true,
//       format: "esm",
//       splitting: true,
//       sourcemap: true,
//       ignoreAnnotations: true,
//       metafile: true,
//     }
//   ).then(server => {
//     console.log("HTTP Server starts at port", server.port);
//   });
// }
runBuild();
